local key = KEYS[1]
local followUserId = ARGV[1]
local timestamp = ARGV[2]

local exists = redis.call('EXISTS', key)
if exists == 0 then
    return -1
end

local size = redis.call('ZCARD', key)
if size >= 1000 then
    return -2
end

if redis.call('ZSCORE', key, followUserId) then
    return -3
end

redis.call('ZADD', key, timestamp, followUserId)
return 0